feat(shared): add isSupportedPlatform helper and unit tests - #555
Conversation
- Add exported isSupportedPlatform helper to platforms.ts - Add tests in __tests__/platforms.test.ts for existing and unknown platform IDs Closes Dev-Card#9
|
@Satvik-art-creator is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel. A member of the Team first needs to authorize it. |
CI — All Checks PassedBackend — SKIP
Mobile — SKIP
Web — SKIP
Last updated: |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a small utility to check whether a platform ID is registered, along with Vitest coverage for expected true/false cases.
Changes:
- Added
isSupportedPlatform(id)helper to the shared platforms registry module - Added Vitest tests covering known/unknown platform IDs and casing behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/shared/src/platforms.ts | Adds isSupportedPlatform to check existence of a platform ID in PLATFORMS. |
| packages/shared/src/tests/platforms.test.ts | Introduces unit tests for isSupportedPlatform across valid/invalid inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use Object.prototype.hasOwnProperty.call for safer own-property check - Remove redundant per-platform assertions covered by the loop test - Rename misleading test description to reflect casing check intent
|
@ShantKhatri Kindly review my pr and merge it under the GSSOC 26 program |
|
Congratulations @Satvik-art-creator on getting PR #555 merged! Thank you for your contribution to the project. To receive the appropriate GSSoC labels and recognition, please mention @Harxhit in the #get-labels channel on our Discord server and share your merged PR link. |
…#555) * feat(shared): add isSupportedPlatform helper and unit tests - Add exported isSupportedPlatform helper to platforms.ts - Add tests in __tests__/platforms.test.ts for existing and unknown platform IDs Closes Dev-Card#9 * fix(shared): address Copilot review feedback on isSupportedPlatform - Use Object.prototype.hasOwnProperty.call for safer own-property check - Remove redundant per-platform assertions covered by the loop test - Rename misleading test description to reflect casing check intent * fix(shared): add vitest types to tsconfig for IDE type resolution
…#555) * feat(shared): add isSupportedPlatform helper and unit tests - Add exported isSupportedPlatform helper to platforms.ts - Add tests in __tests__/platforms.test.ts for existing and unknown platform IDs Closes Dev-Card#9 * fix(shared): address Copilot review feedback on isSupportedPlatform - Use Object.prototype.hasOwnProperty.call for safer own-property check - Remove redundant per-platform assertions covered by the loop test - Rename misleading test description to reflect casing check intent * fix(shared): add vitest types to tsconfig for IDE type resolution
Add exported isSupportedPlatform helper to platforms.ts
Add tests in tests/platforms.test.ts for existing and unknown platform IDs
Closes #9
Summary
Adds a new
isSupportedPlatform(id: string): booleanhelper function topackages/shared/src/platforms.tsthat safely checks whether a given platform ID exists in thePLATFORMSregistry. This improves API discoverability and provides a clean, type-safe way to validate platform IDs without directly accessing the registry object. Corresponding unit tests are added covering all registered platforms, specific known IDs, and edge cases (unknown IDs, empty strings, case sensitivity).Closes #9
Type of Change
What Changed
packages/shared/src/platforms.ts— AddedisSupportedPlatform(id: string): booleanhelper usingPLATFORMS[id] !== undefined, placed alongside existing helpers (getPlatform,getAllPlatforms).packages/shared/src/__tests__/platforms.test.ts— New test file with 8 test cases covering: all registered platform IDs returntrue, specific platforms (github,linkedin,twitter,stackoverflow), and edge cases where unknown/empty/misspelled IDs returnfalse.How to Test
npm --prefix packages/shared installnpx --prefix packages/shared vitest run__tests__/platforms.test.ts).Checklist
pnpm -r run lintpasses).pnpm -r run typecheck).pnpm -r run test).console.logor debug statements left in the code.Screenshots / Recordings
N/A — No UI changes.
Additional Context
packages/shared/src/index.ts(which re-exports* from './platforms'), making it immediately available to all consumers of@devcard/shared.